import random

import math

soup = [{'name': '萝卜排骨汤', 'price': 20}, {'name': '海蛎豆腐汤', 'price': 18},
        {'name': '肉皮酸辣汤', 'price': 18}, {'name': '猪血酸辣汤', 'price': 15}, {'name': '榨菜肉丝汤', 'price': 12},
        {'name': '紫菜蛋花汤', 'price': 12}]
meat = [{'name': '海蛎抱蛋', 'price': 25}, {'name': '清蒸黄瓜鱼', 'price': 32}, {'name': '清蒸鲳鱼', 'price': 25},
        {'name': '糖醋鱼', 'price': 25}, {'name': '荔枝肉', 'price': 28}, {'name': '醉排骨', 'price': 28},
        {'name': '辣子鸡', 'price': 28}, {'name': '黄焖鸡', 'price': 28},
        {'name': '爆炒猪舌', 'price': 23}, {'name': '爆炒猪肝', 'price': 23}, {'name': '爆炒鸭胗', 'price': 25},
        {'name': '红烧猪蹄', 'price': 25}, {'name': '南煎肝', 'price': 23}, {'name': '蒜苔炒猪耳', 'price': 28},
        {'name': '蒜苔炒罗汉肉', 'price': 28},
        {'name': '猪肚炒笋', 'price': 28}, {'name': '葱油花蛤', 'price': 15}, {'name': '腐竹炒肉片', 'price': 18},
        {'name': '回锅肉', 'price': 18}, {'name': '红烧肉', 'price': 20}, {'name': '红烧带鱼', 'price': 23},
        {'name': '爆炒小肠', 'price': 23}, {'name': '爆炒猪心', 'price': 23}]
vegetable = [{'name': '干锅包菜', 'price': 18}, {'name': '干锅花菜', 'price': 18}, {'name': '山药炒木耳', 'price': 18},
             {'name': '虎皮尖椒', 'price': 15}, {'name': '红烧茄子', 'price': 12}, {'name': '西红柿炒蛋', 'price': 12},
             {'name': '酸辣土豆丝', 'price': 10},
             {'name': '清炒时蔬', 'price': 10}]

sum_price = 0


def how_many_dish(person_number):
    if int(person_number) > 8:
        dish_count = 8
    else:
        dish_count = person_number
    soup_number = 1
    meat_number = math.ceil((dish_count - soup_number) / 2)
    vegetable_number = math.floor((dish_count - soup_number) / 2)
    return soup_number, meat_number, vegetable_number


def get_rice(person_number):
    global sum_price
    print("饭：" + str(person_number))
    sum_price += person_number


def get_soup(soup_number):
    global sum_price
    temp = []
    print("汤：")
    cycle_count = soup_number
    for i in range(0, cycle_count):
        ran = random.randint(0, len(soup) - 1)
        if temp.count(ran) == 0:
            temp.append(ran)
            print(soup[ran]['name'] + " " + str(soup[ran]['price']))
            sum_price += soup[ran]['price']
        else:
            cycle_count += 1
        if cycle_count > 99:
            break
    return soup_number


def get_meat(meat_number):
    global sum_price
    temp = []
    print("荤菜：")
    cycle_count = meat_number
    for i in range(0, meat_number):
        ran = random.randint(0, len(meat) - 1)
        if temp.count(ran) == 0:
            temp.append(ran)
            print(meat[ran]['name'] + " " + str(meat[ran]['price']))
            sum_price += meat[ran]['price']
        else:
            cycle_count += 1
        if cycle_count > 99:
            break


def get_vegetable(vegetable_number):
    global sum_price
    temp = []
    print("素菜：")
    cycle_count = vegetable_number
    for i in range(0, vegetable_number):
        ran = random.randint(0, len(vegetable) - 1)
        if temp.count(ran) == 0:
            temp.append(ran)
            print(vegetable[ran]['name'] + " " + str(vegetable[ran]['price']))
            sum_price += vegetable[ran]['price']
        else:
            cycle_count += 1
        if cycle_count > 99:
            break


def how_much(person_number):
    print("共计：" + str(sum_price + person_number))
    print("人均约：" + str(round(sum_price / int(person_number), 2) + 1))


if __name__ == "__main__":
    person_number = input("几个人吃:")
    if person_number.isdigit():
        person_number = int(person_number)
        soup_number, meat_number, vegetable_number = how_many_dish(person_number)
        get_soup(soup_number)
        get_meat(meat_number)
        get_vegetable(vegetable_number)
        how_much(person_number)
    else:
        print("输入不正确")
